package com.view;

import com.usercarshow.MainActivity;
import com.usercarshow.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ViewFlipper;

public class ExhibitDetailPanel extends Activity {
	// "主页" 按钮
	private Button home;
	// 返回到 “上一页” 按钮
	private Button back;
	private Button basic_info;
	private Button basic_property;
	private Button structure;
	private Button outer_size;
	private Button inner_size;
	private Button fuel_oil;
	private ViewFlipper car_info;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
		setContentView(R.layout.exhibit_detail_hot);
		home = (Button) findViewById(R.id.home);
		back = (Button) findViewById(R.id.back);

		basic_info = (Button) findViewById(R.id.basic_info);
		basic_property = (Button) findViewById(R.id.basic_property);
		structure = (Button) findViewById(R.id.structure);
		outer_size = (Button) findViewById(R.id.outer_size);
		inner_size = (Button) findViewById(R.id.inner_size);
		fuel_oil = (Button) findViewById(R.id.fuel_oil);

		car_info = (ViewFlipper) findViewById(R.id.car_info);
		// 设置动画--自定义动画
		// car_info.setInAnimation(AnimationUtils.loadAnimation(this,
		// R.anim.push_up_in));
		// car_info.setInAnimation(AnimationUtils.loadAnimation(this,
		// R.anim.push_up_out));
		car_info.setInAnimation(AnimationUtils.loadAnimation(this,
				android.R.anim.fade_in));
		car_info.setInAnimation(AnimationUtils.loadAnimation(this,
				android.R.anim.fade_out));

		home.setOnClickListener(clickListener);
		back.setOnClickListener(clickListener);
		basic_info.setOnClickListener(clickListener);
		basic_property.setOnClickListener(clickListener);
		structure.setOnClickListener(clickListener);
		outer_size.setOnClickListener(clickListener);
		inner_size.setOnClickListener(clickListener);
		fuel_oil.setOnClickListener(clickListener);
	}

	private OnClickListener clickListener = new OnClickListener() {
		@Override
		public void onClick(View view) {
			if (view.getId() == R.id.home) { // 返回主页
				home.setAnimation(AnimationUtils.loadAnimation(
						ExhibitDetailPanel.this, R.anim.button_anim));
				Intent intent = new Intent(ExhibitDetailPanel.this,
						MainActivity.class);
				ExhibitDetailPanel.this.startActivity(intent);
				ExhibitDetailPanel.this.overridePendingTransition(
						android.R.anim.fade_in, android.R.anim.fade_out);
			} else if (view.getId() == R.id.back) { // 后退
				back.setAnimation(AnimationUtils.loadAnimation(
						ExhibitDetailPanel.this, R.anim.button_anim));
				Intent intent = new Intent(ExhibitDetailPanel.this,
						ExhibitHot.class);
				ExhibitDetailPanel.this.startActivity(intent);
				ExhibitDetailPanel.this.overridePendingTransition(
						android.R.anim.fade_in, android.R.anim.fade_out);
			} else if (view.getId() == R.id.basic_info) { // 基本信息
				car_info.showNext();
			} else if (view.getId() == R.id.basic_property) { // 基本属性
				car_info.showNext();
			} else if (view.getId() == R.id.structure) { // 结构
				car_info.showNext();
			} else if (view.getId() == R.id.outer_size) { // 外部尺寸
				car_info.showNext();
			} else if (view.getId() == R.id.inner_size) { // 内部尺寸
				car_info.showNext();
			} else if (view.getId() == R.id.fuel_oil) { // 燃油
				car_info.showNext();
			}
		}
	};
}
